﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AgencyEntityLib.BaseEntity;

public partial class iFrameAdmin_EditDiscount : iAdmin_Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) DataBind(); 

        
     
    }
    protected void btnSaveCommonInfo_Click(object sender, EventArgs e)
    {
        ReadForm();
        wsAgency ws = new wsAgency();
        Discount g = ws.SaveDiscount(Discount);
        if (IsNewRecord) Response.Redirect("iFrameAdmin_EditDiscount.aspx?" + qDiscountID + "=" + g.ID);  
    }
    protected bool IsNewRecord
    {
        get { return DiscountID.IndexOf(GlobalConstants.qPrefNEW_RECORD) > -1; }
    }
    private void ReadForm()
    {
        Discount.Name = txtName.Text;
        Discount.Description = txtComment.Text;
        Discount.Percent = Convert.ToInt16(txtPercent.Text);
        Discount.dtStart = Convert.ToDateTime(txt_dtStart.Text);
        Discount.dtFinish = Convert.ToDateTime(txt_dtFinish.Text);
    }

    protected string DiscountID
    {
        get { return Request.QueryString[qDiscountID]; }
    }
    protected Discount Discount
    {
        get
        {
            wsAgency ws = new wsAgency();
            return ws.GetDiscount(DiscountID);
        }

    }

    protected string GetStateVisible()
    {
    //    if (SurfaceGroup.State != EntityState.Loaded) return string.Empty;
    //    foreach (Entity item in SurfaceGroup.SurfaceList)
    //    {
    //        if (item.State != EntityState.Loaded) return string.Empty;
            
      //  }
    
    return "hidden";    
    }
}
